﻿#pragma execution_character_set("utf-8")
#ifndef MOVEOPERATION_H
#define MOVEOPERATION_H
#pragma execution_character_set("utf-8")
#include "globaldata.h"
#include <QTimer>
#include <QTranslator>
#include "communicatedelegate_global.h"

class  MoveOperation : public QObject
{
    Q_OBJECT
public:
    MoveOperation(GlobalData *globalDataIn,int allowMaxJogTime);
    bool isJogTimerActive();


public:
    //提供外部调用::
    //寸动部分
    void startJogMove(int keyIdIn, int directionIn);//分页处理　．keyIdIn不等于轴号
    void stopJogMove();
//    void setJogFlag();

    //移动到点部分
    void startPointMove(MoveParameter movePoint);
    void stopPointMove();

    //报警清除状态 并且停止
    void warmStopMove();

public slots:
    void setMaxJogTimeSlot(int timeIn);

private:
    /**
     * @brief globalData    公共数据指针
     */

    //GlobalData *ioData;

    //寸动部分
    /**
     * @brief jogTimer      寸动定时器
     */
    QTimer *jogTimer;

    /**
     * @brief jogFirst      寸动状态判断
     */
    bool jogFirst;
    /**
     * @brief axisNumber    当前轴
     */
    int jogAxisKeyId;
    /**
     * @brief direction     方向
     */
    int direction;

    //移动到点部分
    /**
     * @brief pointTimer    点移动定时器
     */
    QTimer *pointTimer;
    /**
     * @brief jogFirst      点移动状态判断
     */
    bool pointFirst;
    /**
     * @brief movePoint     移动数据
     */
    MoveParameter movePoint;

    QTranslator translator;
    GlobalData *globalData;

signals:
    /**
     * @brief msgBoxSignal  通知 打开消息框
     */
    void msgBoxSignal(int type,QString title,QString text);

    //**********通信部分*******************
    //运动喂狗
    void runningDog();

    //寸动
    /**
     * @brief jogRunning                    寸动 信号
     * @param axisNumber
     * @param direction
     */
    void moveJogSignal(int jogAxisKeyId,int direction);

    //移动到点
    /**
     * @brief moveToPointSignal             移动到点 信号
     * @param movePoint
     */
    void movePointSignal(MoveParameter movePoint);

    //停止
    /**
     * @brief moveToPointSignal             停止 信号
     * @param movePoint
     */
    void stopRunSignal();
    void ceaseRunSignal();

    void stopWatchDogSignal();

public slots:
    /**
     * @brief jogTimeWork   寸动定时发送
     */
    void jogTimeWork();
    /**
     * @brief pointTimeWork 点移动定时发送
     */
    void pointTimeWork();

    /**
     * @brief changeLanguageSlot            修改语言
     */
    void changeLanguageSlot(int language);

private:
    int continuouseMoveCount;
    int allowMaxJogCount;
};

#endif // MOVEOPERATION_H
